package com.zb.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zb.dto.UserDTO;
import com.zb.entity.TbUserModel;
import com.zb.service.TbUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tb-user-model")
public class TbUserController {

    @Autowired
    TbUserService tbUserService;

    @GetMapping("/info/{username}")
    public UserDTO getUserInfo(@PathVariable("username") String username){
        LambdaQueryWrapper<TbUserModel> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbUserModel::getUsername,username);
        TbUserModel one = tbUserService.getOne(wrapper);
        UserDTO userDTO = new UserDTO();
        BeanUtils.copyProperties(one,userDTO);
        return userDTO;
    }
}
